package com.ruoyi.biz.enums;

import com.alibaba.fastjson2.JSONObject;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author tianl
 * @date 2025/1/2
 * @description:
 */
@Getter
public enum CostTypeEnum {
    COST_MANAGE_PER("暂估管理绩效", "1", true),
    COST_AGREE_PER("暂估技术绩效", "2", true),
    COST_TAX("实得额税费", "3", true),
    COST_BASE("基础成本", "4", true),
    COST_CHANNEL("渠道费", "5", true),
    COST_OUT("委外支出", "6", false),
    COST_TRAVEL("差旅费", "7", false),
    COST_OTHER("其他", "8", false),
    ;

    private String name;

    private String code;
    private Boolean disabled;

    CostTypeEnum(String name, String code, Boolean disabled) {
        this.name = name;
        this.code = code;
        this.disabled = disabled;
    }

    public static List<JSONObject> toList() {
        List<JSONObject> list = new ArrayList<>();
        for (CostTypeEnum costTypeEnum : CostTypeEnum.values()) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("name", costTypeEnum.getName());
            jsonObject.put("code", costTypeEnum.getCode());
            jsonObject.put("disabled", costTypeEnum.getDisabled());
            list.add(jsonObject);
        }
        return list;
    }

    public static List<String> getDefaultCode() {
        List<CostTypeEnum> enums = Arrays.stream(CostTypeEnum.values()).filter(r -> r.disabled).collect(Collectors.toList());
        return enums.stream().map(CostTypeEnum::getCode).collect(Collectors.toList());
    }
}
